﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Common;

namespace Infrastructure.Data.Security
{
    using Domain.UserManagement;
    using System.Linq.Expressions;
    using Domain.UserManagement.Entities;
    using Infrastructure.Common.Data;

    public class RoleRepository : Repository<Role>, IRoleRepository
    {
        public RoleRepository(IContext context)
            : base(context)
        { }

        public override Role Add(Role item)
        {
            return this.Context.Roles.Add(item);
        }

        public override void Update(Role item)
        {
            throw new NotImplementedException();
        }

        public override void Delete(Role item)
        {
            throw new NotImplementedException();
        }

        public override IEnumerable<Role> Get(params Expression<Func<Role, bool>>[] predicates)
        {
            var q = from s in this.Context.Roles select s;

            if (predicates != null)
            {
                foreach (var predicate in predicates)
                {
                    q = q.Where(predicate);
                }
            }

            return q.ToArray();
        }
    }
}
